package baidu.ui.controls
{
    import baidu.ui.core.*;
    import flash.display.*;
    import flash.text.*;

    public class Tooltip extends baidu.ui.core.BUI
    {
        public function Tooltip()
        {
            super();
            return;
        }

        public override function get classStyles():Object
        {
            return baidu.ui.core.BUI.mergeStyles(super.classStyles, defaultStyles);
        }

        public function get text():String
        {
            return this.textField.text;
        }

        public function set text(arg1:String):void
        {
            this.textField.text = arg1;
            invalidate(baidu.ui.core.Invalidation.SIZE);
            invalidate(baidu.ui.core.Invalidation.STYLES);
            return;
        }

        protected override function initUI():void
        {
            super.initUI();
            this.textField = new flash.text.TextField();
            addChild(this.textField);
            this.textField.autoSize = "left";
            return;
        }

        protected override function draw():void
        {
            if (isInvalid(baidu.ui.core.Invalidation.STYLES, baidu.ui.core.Invalidation.STATE))
            {
                this.drawBackground();
                invalidate(baidu.ui.core.Invalidation.SIZE, false);
            }
            if (isInvalid(baidu.ui.core.Invalidation.SIZE))
            {
                this.drawLayout();
            }
            super.draw();
            return;
        }

        protected function drawLayout():void
        {
            var loc1:*;
            loc1 = getStyleValue("padding");
            var loc2:*;
            this.background.width = loc2 = this.textField.width + loc1 * 2;
            _width = loc2;
            this.background.height = loc2 = this.textField.height + loc1 * 2;
            _height = loc2;
            this.textField.y = loc2 = loc1;
            this.textField.x = loc2;
            return;
        }

        protected function drawBackground():void
        {
            var loc1:*;
            loc1 = this.background as flash.display.MovieClip;
            this.background = getSkinInstance(getStyleValue("skin")) as flash.display.Sprite;
            addChildAt(this.background, 0);
            if (!(loc1 == null) && !(loc1 == this.background) && contains(loc1))
            {
                removeChild(loc1);
            }
            return;
        }


        {
            defaultStyles = {"skin":"Tooltip_Skin", "padding":2};
        }

        protected var textField:flash.text.TextField;

        protected var background:flash.display.Sprite;

        public static var defaultStyles:Object;
    }
}
